'use strict';function _Uu(m){return _To(m,!1,!0)}
let _My=(()=>{function m(a,b,d){function c(h){let k=_er(h,"action");h==a&&(e=f,g=k.grp);return`<item value=${h} ${h==a?"selected":""} ${k.perms?`perms="${k.perms}"`:""}>${k.name} ${k.h?`<h h=${h}/_></h>`:""}</item>`}let f,e=b?"adv":"basic",g;b=$(`\n <actionSelector DataModule ${b?"noBasic":""} helpCtx=actList>\n <content>\n <pane ${f="basic"}>\n <cont>\n <column>\n ${c("goBack")} ${c("goForward")} ${c("reload")} ${c("zoomIn")} ${c("zoomOut")}<hr>\n ${c("pin")} ${c("mute")} ${c("duplicate")} ${c("detach")} <hr>\n ${c("openNTP")} ${c("openElemUrl")} ${c("saveElemUrl")}\n </column>\n <column>\n ${d?"<item>No action</item> <hr>":
""}\n ${c("switchPrev")} ${c("switchLeft")} ${c("switchRight")}\n ${c("switchLeftmost")} ${c("switchRightmost")}\n <hr>\n ${c("close")} ${c("closeLefts")} ${c("closeRights")}\n ${c("closeOther")} ${c("closeWin")}\n <hr>\n ${c("reopen")}\n </column>\n </cont>\n </pane>\n <pane ${f="adv"}>\n <groups>\n ${[...n].map(([h,k])=>`<it grp=${h}>${k.name} <h h=${k.h||""}></h></it>`).join("")}\n </groups>\n <conts>\n ${[...n].map(([h,k])=>`<it ${h}>${k.members.map(c).join("")}</it>`).join("")}\n </conts>\n </pane>\n </content>\n <tabs>\n <tab pane=basic>Basic Actions</tab>\n <tab pane=adv>Advanced Actions</tab>\n </tabs>\n </actionSelector>\n `).on("click",
"item",function(h){$(h.delegateTarget).triggerEvt({itemSelect:$(this).attr("value")});$(this).triggerEvt("focusLost",!0)}).on("mousedown","tab",function(h){$(`> content > [${$(this).attr("pane")}]`,h.delegateTarget).add(this).attr("selected","").siblings().attr("selected",null)}).on("mousedown","groups > it",function(){$(this).closest("pane").find(`it[${$(this).attr("grp")}]`).add(this).attr("selected","").siblings().attr("selected",null)});$(`[pane=${e}]`,b).trigger("mousedown");$(`[grp=${g||"tab"}]`,
b).trigger("mousedown");return b}function v(a,b){let d=$("[name=action]",a).attr("value"),c=m(d,0<_Xt(a),!!b).on("itemSelect",function(f,e){if(d!=e){f=$(a).closest("action").find("[name=targets]");!f.is(":visible")&&$(a).closest("trigAct").find("combinSeq:first event:last").hasClass("mouse")&&_Cg(f[0],"hoveredTabs");let g=p({action:e,params:{}});$(a).replaceWith(g);_nt(g);q(g);_Vy(d,"setSwtchSt","brkActSeq")&&_dj(800);"openMenu"==d&&_Pw(800);w.paramsGuiGen[e]&&setTimeout(()=>g.find(">l").triggerEvt({mousedown:!0},
!0),300)}else if(!e){let g=a.closest("content");setTimeout(()=>{_Jh("\n <help>Leave this field empty if you want to disable a shortcut. <hr b> i.e. the trigger will fire no action.</help>\n ",$("actionStep > fld",g),"rbtl","helpBubble","","opacity")},100)}}).on("focusLost",()=>{$(a).is(":visible")&&!$(a).attr("value")&&x(a)}).on("DOMInserted",function(){var f=$("h",a);if("visible"==f.css("visibility")){let g=f[0].getBoundingClientRect();var e="/"+_Xi(f.attr("h"),_hk(f)).join("/");f=f.clone().attr("h",
e).css({position:"absolute",margin:0}).appendTo(c);f[0].offsetParent&&(e=f[0].offsetParent.getBoundingClientRect(),f.css({left:g.left-e.left,top:g.top-e.top}))}});_Jh(c,a,"btrl ,VR","tailOnly noTail");$("item[selected]",c).each(function(){this.scrollIntoViewIfNeeded(!0)})}function B(a){var b=$(a).attr("value");let d=0,c="";for(let f of _Ws("tse",!0))c+=`${++d%2?"<tr customTse>":""}<td>${_yj("tse",f,b)}`;b=$(`\n <targetSelector popupCntr DataModule>\n <scrollWrap>\n <table><tr>\n <td>\n ${_yj("tse",
"currentTab",b)}\n ${_yj("tse","newestTab",b)}\n ${_yj("tse","openerTab",b)}\n ${_yj("tse","eventTabs",b)}\n ${_yj("tse","hoveredTabs",b)}\n <hr>\n ${_yj("tse","leftTab",b)}\n ${_yj("tse","allLeftTabs",b)}\n ${_yj("tse","firstTab",b)}\n <hr>\n ${_yj("tse","prevUsedTab",b)}\n ${_yj("tse","prevUsedTabAnyWin",b)}\n ${_yj("tse","nextUsedTab",b)}\n ${_yj("tse","nextUsedTabAnyWin",b)}\n </td><td>\n ${_yj("tse","activeTabs",b)}\n ${_yj("tse","highlighted",b)}\n ${_yj("tse","pinnedTabs",b)}\n ${_yj("tse",
"audibleTabs",b)}\n ${_yj("tse","nonMinimTabs",b)}\n <hr>\n ${_yj("tse","rightTab",b)}\n ${_yj("tse","allRightTabs",b)}\n ${_yj("tse","lastTab",b)}\n <hr>\n ${_yj("tse","otherTabs",b)}\n ${_yj("tse","otherTabsAllWins",b)}\n ${_yj("tse","currWinTabs",b)}\n ${_yj("tse","allTabs",b)}\n </td> \n ${c}\n </table>\n </scrollWrap>\n <newEntity type=tse>Choose more tabs...</newEntity>\n </targetSelector>\n `);return _1r(b,a)}function y(a){let {action:b,params:d={}}=a;if(b.in("undoClose","selectMarkedItem",
"runScript"))return!0;if(b.in("loadUrls","openBookmarks"))return!!d.tabPos;a=_vj(b,d);if("object"==typeof a&&a[0]){var c;if(!(c=1<a.length||a[0].targets))a:{a=a[0].sequence;for(let f of a)if(y(f)){c=!0;break a}c=!1}return c}return!1}function C(a){let {action:b,params:d={}}=a;if(b.in("undoClose","openMenu","closeMenu","moveSelectMark","selectMarkedItem","stopSendInput","clpbrdCut","clpbrdCopy","clpbrdPaste","copyLinks","extractURLs","delDupLines","copyElemUrl","setSwtchSt","setVolume","setMonBright",
"setMonPower","screenSaver","showDesktop"))return!1;switch(b){case "loadUrls":return!d.tabPos||d.usesTabs;case "openBookmarks":return!d.tabPos;case "clpbrdPut":case "insertText":return d.usesTabs&&!d.verbatim;case "runCommand":return d.usesTabs;case "saveUrl":return d.usesTabs;case "txtToUrl":return d.usesTabs;case "playAudio":return d.usesTabs;case "scrollWins":return!d.pointedElem;case "sendInput":return d.intoPage;case "runScript":return!d.bkgrnd;case "wait":return+d.event<_f;case "brkActSeq":return(d.conds||
[]).some(c=>"tgtTabs"==c.type||c.usesTabs);case "bookmarkUrls":return d.usesTabs}a=_vj(b,d);return"object"==typeof a?a[0]&&null==a[0].targets&&r(a[0].sequence):!0}function r(a=[]){let b=!1;for(let d of a){if(C(d)&&!b)return!0;b||(b=y(d))}return!1}function t(a){let b=D[a.action],d=_er(a.action,"action").name;return b&&!_Pt(a.params)&&(b(a.params)||"").replace("\v",d)||d}function z(a,b){a=$(`actionStep > [entId='${a}']`);a.length&&a.html(t(_pu(b||a.first().parent()[0])))}function A(a){switch(a.action){case "runScript":return a.params.scriptId}}
function p(a,b=!0){if(a){b=_Bj(_lo);var d=a.action,c=A(a);a=b`\n <actionStep value={}>\n <l name=action value=${d} ${c?"entId="+c:""}>${t(a)}</l><b></b>\n <par name=params value=$${a.params}></par>\n </actionStep>\n `}else a=$(`<actionStep><fld>Choose an action</fld>${b?"<h h=selAct></h>":""}</actionStep>`);return a}function u(a){a=a||{};return _Bj`\n <action value={}>\n <actSeq name=sequence value=[] needsTgtTabs=${r(a.sequence)}>\n ${(_Pt(a.sequence)?[null]:a.sequence).map(b=>[p(b),"<sep button actBtn hh=newStp></sep>"])}\n </actSeq>\n <targets>\n Apply to: ${_wt("tse",
"targets",a.targets||"currentTab")} <h h=tgtsFld></h>\n </targets>\n <ctrl>\n <del button title="Delete this action chain">&#xD7;</del>\n <move button up title="Move up">&#x25B4;</move>\n <move button down title="Move down">&#x25BE;</move>\n </ctrl>\n </action>\n `}function x(a){$(a).closest("action").replaceWith(u(_To(a.closest("action"))))}function q(a){var b=r(_To(a.closest("action")).sequence);a=$(a).closest("actSeq").attr("needsTgtTabs",b);b||(b=a.closest("action").find("[name=targets]"),_xp(b.attr("value"))&&
_Cg(b[0],"currentTab"))}const w=document.currentScript.parentElement,n={tab:{name:"Tab Actions"},win:{name:"Window Actions",h:"../winAct2"},bmrk:{name:"Bookmark Actions"},menu:{name:"Menu Actions",h:"../menu"},clbrd:{name:"Clipboard Actions",h:"/clpbrd"},sys:{name:"System Actions"},exec:{name:"Execution Control"},other:{name:"Other"}};for(let [a,b]of _hf._2i.action)b.grp&&_ih(n[b.grp],"members",[]).push(a);const l=a=>({[_Bf]:"Un\v",[_up]:"Toggle \v"})[a.mode],D={activateTabs:a=>a.peek&&"Peek tabs",
highlightTabs:l,muteTabs:l,pinTabs:l,zoomTabs:a=>0<a.type?"Zoom in tabs":0>a.type?"Zoom out tabs":Number.isNaN(+a.type)?null:"Reset tabs zoom",focusWin:l,minimizeWins:l,maximizeWins:l,fullscreenWins:a=>({[_Bf]:"Exit \v",[_up]:"Toggle \v"})[a.mode],hideWins:l,topmostWins:a=>({[_be]:"Set",[_Bf]:"Unset",[_up]:"Toggle"})[a.mode]+" topmost",scrollWins:a=>"Scroll "+a.dir,moveSelectMark:a=>0>a.dir?"\v back":"\v fwd.",openElemUrl:a=>"Open "+{lnk:"Link",mda:"Media"}[a.type]+" URL",setVolume:a=>({up:"Increase",
down:"Decrease",toggle:"Toggle mute"}[a.mode]||a.mode)+" volume",setMonBright:a=>({up:"Increase",down:"Decrease"}[a.mode]||a.mode)+" brightness",brkActSeq:a=>("stopChn"==a.action?"Stop chain":"stopSeq"==a.action?"Stop entire seq":"Continue chain")+(_Pt(a.conds)?"":" if"),wait:a=>"time"==a.event?"\v time":"\v event",setSwtchSt:a=>1==a.state?"Set switch ON":0==a.state?"Set switch OFF":"Toggle switch",runScript:a=>(a=_er(a.scriptId,"script").name)&&`<c>\v:</c><d>${a}</d>`,groupTabs:a=>"no"==a.target?
"Un\v":"\v"};let E=_wj(function*(a){function b(){const e=0==$(a).prevAll(a.tagName).length,g=0==$(a).nextAll(a.tagName).length,h="object"==typeof _er(d.action,"action").value;return e&&g||h?null:e?"first":g?"last":"middle"}let d=_To(a),c=$(`\n <optPane actStep=${d.action} DataModule value={} helpCtx="actList/${d.action}">\n <noParams>No settings for<br> this action</noParams>\n <div actions><btn dir=lft title="Move action to the left">&lt;</btn><btn del>Delete action</btn><btn dir=rgt title="Move action to the right">&gt;</btn></div>\n </optPane>\n `).attr("pos",
b()).on("dblclick","btn[del]",function(){_rg($(this).closest("optPane"))&&_dj(500);"openMenu"==d.action&&_Pw(500);let e=a.closest("action");$(this).triggerEvt("focusLost",!0);a.remove();_nt(e);x(e)}).on("click","btn[dir]",function(){var e=$(this).attr("dir");e=$(a)["lft"==e?"prevAll":"nextAll"](a.tagName).first();var g=e.find("> l").attr("value");"object"==typeof _er(g,"action").value?(g=_er(g,"action").name,_Jh(`\n <help noPopupAround>\n <act>${g}</act> is a <b>basic action</b>, it cannot be moved. <hr b> Basic actions can only be the first step of an action chain.\n Following <br> steps must be <b>advanced actions</b> only. <hr b>\n You can use an <a href='${_Ce.actions}#sequence'>unchained sequence</a> instead, to put basic actions in <br> any position.\n </help>\n `,
e,"ltbr","helpBubble big","","opacity")):(g=a.nextElementSibling,e.after(a),$(g).before(e),c.attr("pos",b()).triggerEvt({resize:!0},!0),q(a),_nt(a))}).on("change input",_Ow(250,function(e){if(!$(e.target).closest("[DataModule]",this)[0]&&document.contains(this)){$("[name=params]",a)[0].value=_9g(_Uu(this));e=_To(a);e=A(e);var g=$("> l",a);e?(g.attr("entId",e),z(e,a)):g.html(t(_pu(a)));q(a);_nt(this)}}));var f=w.paramsGuiGen[d.action];if(f){f=f({params:{}}.add(d),c[0]);"function"==typeof f&&(f=yield f);
let e=(f instanceof jQuery?f[0]:f).onInsert;$("noParams",c).replaceWith(f);e&&(c.appendTo("hiddenDoc"),e())}return c});return{make:function(a=[],b=""){return _Bj`\n <actions trigOrAct DataModule popupCntr helpCtx ${_Pt(a)?"class=empty":""} name="${b}" value=[]>\n <header>Action <selector><add button actBtn hh=addAct></add></selector></header>\n <content>${(a.length?a:[null]).map(u)}</content>\n </actions>\n `},setEvtLtnrs:function(a){$(a).attr("optionsCollection","").on("mousedown","actionStep > l:not(.popup)",
function(b,d){E(this.closest("actionStep"))(c=>{_Jh(c,this,"btrl ,AO","tailOnly noTail");d&&c.triggerEvt("change")})}).on("mousedown","actSeq > actionStep:not([value])",function(){v(this,$(this).closest("action").is(":only-of-type"))}).on("click","actSeq > sep",function(){$(this).after(p(null,!1),"<sep></sep>");setTimeout(()=>$("~ actionStep:not([value])",this).first().triggerEvt("mousedown",!0),200)}).on("mousedown","actionStep > b",function(){v($(this).closest("actionStep")[0])}).on("mousedown",
"action > targets customSelect",function(){let b=B(this).on("focusLost",function(){$(this).triggerEvt("close").remove()});_Jh(b,this,"blrt ,VR");$("item[selected]",b).each(function(){this.scrollIntoViewIfNeeded(!0)});return!1}).on("change","action > targets customSelect",function(){_nt(this)}).on("click","actions > header add",function(){let b=$(this).closest("actions");$("action:last-of-type actionStep[value]",b)[0]&&b.find("> content").append(u())}).on("dblclick","action > ctrl del",function(){let b=
$(this).closest("action");b.find("[value=openMenu]")[0]&&_Pw(500);b.find("[value=brkActSeq], [value=setSwtchSt]")[0]&&_dj(500);let d=this.closest("actions");b.remove();_nt(d)}).on("click","action > ctrl move",function(){_Lp(this.closest("action"),$(this).is("[down]")?1:-1,400);_nt(this)}).on("change","actions",function(){$(this).toggleClass("empty",!$("sep:visible",this).length)})},updActLbl:z}})();
